<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script src='https://cdn.staticfile.org/react/16.4.0/umd/react.development.js'></script>
    <script src='https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js'></script>
    <!-- 生产环境中不建议使用 -->
    <script src='https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js'></script>
</head>

<body>
    <div id='app'>
    </div>
    <script type='text/babel'>
        class Weather extends React.Component{

            constructor(props){
                super(props)
                this.state = {isHot:true}
            }

            render(){
                // 注意jsx里面的标签都是虚拟DOM, 所以不能直接写onclick, react中是用驼峰式写法代替. 另外要注意onClick后面不要像原生html一样直接写"demo()". 会被直接解析为字符串, 所以要用大括号形式. 一句话总结来说就是, 千万不要习惯性的用原生html,js的语法直接写在jsx里.
                return <h1 onClick={demo}>天气很{this.state.isHot?"炎热":'凉爽'}</h1>
            }
        }

        function demo(){
            console.log('h1被点击了')
        }

        ReactDOM.render(<Weather/>,document.getElementById('app'))
    </script>
</body>

</html>